<template>
	<view class="my-invite" ref="uv-back-top">
		<headers ></headers>
		<el-container>
			<el-aside class="hidden-sm-and-down" width="500px">
				<my :heads="false"></my>
			</el-aside>
			<el-main>
				<view class="in-content">
					<view class="in-item">
						<uv-row justify="center" customStyle="margin-bottom: 10px">
							<el-result icon="success" title="充值成功" subTitle="请根据提示进行操作">
								<template slot="extra">
									<el-button type="primary" size="medium">返回</el-button>
								</template>
							</el-result>
						</uv-row>
					</view>
				</view>
			</el-main>
		</el-container>
		<uv-navbar v-if="!screen" :title="'邀 请'" @leftClick="navigateBack" :placeholder="true"></uv-navbar>

		<uv-toast ref="toast"></uv-toast>
	</view>
</template>

<script>
	// import QRCodeStyleRound from '@/uqrcode.plugin.round.es.js';
	import my from '@/pages/my/index'
	import headers from '@/components/header/header.vue';
	import config from '@/common/config'
	import {
		addInviteCode,
	} from '@/common/api.js';
	export default {
		components: {
			// 注册组件
			my,
			headers,
		},
		data() {
			return {
				scrollTop: 0,
				qrcode: '',
				loginUrl: config.loginUrl,
				options2: {
					// data: 'https://www.uvui.cn',
					size: 300,
					useDynamicSize: false,
					errorCorrectLevel: 'Q',
					margin: 10,
					areaColor: "#ffffff",
					backgroundColor: "#FFF",
					// 指定二维码前景，一般可在中间放logo
					foregroundImageSrc: config.appName == '元画' ? '/static/logo2.png' : '/static/logo.png',
				}
			}
		},
		computed: {},
		onLoad() {},
		onReady() {
			/* 注册扩展插件 */
			// this.$refs.qrcode.registerStyle(QRCodeStyleRound); // qrcode为组件的ref名称
		},
		onPageScroll(e) {
			this.scrollTop = e.scrollTop;
			// #ifdef APP-NVUE
			this.scrollTop = e.detail.scrollTop;
			// #endif
		},
		methods: {
			submit() {
				var that = this;
				that.$refs.toast.show({
					message: "保存中..."
				});
				if (that.qrcode) {
					addInviteCode({
						inviteCode: that.qrcode,
					}, {
						custom: {
							auth: true,
						},
					}).then(e => {
						// 显示 Toast
						this.$refs.toast.show({
							title: '默认主题',
							message: "保存成功！"
						})
						this.$forceUpdate();
					}).catch(e => {
						console.log(e);
					})
				} else {
					that.$refs.toast.show({
						message: "邀请码为空"
					});
				}
			},
			save() {
				this.$refs.qrcode.save({
					success: (res) => {
						console.log(res);
						this.$refs.toast.show({
							title: '默认主题',
							message: "保存成功！"
						})
					}
				});
			},
			routed(url) {
				console.log('routed', url)
				uni.$uv.route({
					url: url,
					intercept(params, next) {
						console.log(params, next)
						uni.showLoading({
							title: '等待中...'
						})
						// 模拟处理等待
						setTimeout(() => {
							uni.hideLoading();
							next(true);
						}, 1000)
					}
				})
			},
		}
	}
</script>

<style scoped lang="scss">
	.my-invite {
		// background-color: #99a9bf;

		// width: calc(100% - 20px);
		.in-content {
			// padding: 10px;

			.in-item {
				margin-bottom: 10px;
				padding: 10px;
				background-color: aliceblue;
				border-radius: 10px;
			}
		}

	}
</style>